<style type="text/css">
    .layui-table-body{overflow-x:auto;}
    .layui-table-cell{font-size:12px;}
</style>
<div class="layui-form hisi-search">
    <form action="{:url()}" method="get" id="hisi-table-search">
        <div class="layui-form-item">
            <label class="layui-form-label">关键词</label>
            <div class="layui-input-inline">
                <input type="text" name="keyword" class="layui-input" lay-verify="required" placeholder="用户名/电话" />
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">分销商等级</label>
            <div class="layui-input-inline">
                <select name="group_id" id="" >
                    <option value="0">所有用户</option>
                    <option value="1">一级分销商</option>
                    <option value="2">二级分销商</option>
                    <option value="-1">C端用户</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item hisi-search-btn">
            <div class="layui-input-inline">
                <button type="submit" class="layui-btn layui-btn-normal layui-icon layui-icon-search">查询</button><button type="reset" class="layui-btn layui-btn-primary layui-icon layui-icon-delete">重置</button>
            </div>
        </div>
    </form>
</div>
<table id="dataTable"></table>
<script type="text/html" id="userTpl">
    <div style="line-height:18px;">
    <img src="{{ d.headimg ? d.headimg : '__ADMIN_IMG__/avatar.png' }}" width="60" height="60" class="fl">
    <p class="ml10 fl">昵称：{{ d.nickname }}</p>
    <p class="ml10 fl">电话：{{ d.phone }}</p>
</div>
</script>
<script type="text/html" title="操作按钮模板" id="buttonTpl">
    <a href="{:url('fx_edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal hisi-iframe-pop"  hisi-data="{width: '1000px', height: '500px', title: '分销商设置'}">分销商设置</a>
    <!-- <a href="{:url('del')}?type=goods&id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a> -->
</script>

<script type="text/html" title="状态模板" id="statusTpl">
    <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="开启|禁用" {{ d.status == 0 ? 'checked' : '' }}  data-href="{:url('status')}?id={{ d.id }}">
</script>
{include file="system@block/layui" /}
<script id="toolbar" type="text/html">
    <a href="{:url('add')}?type=goods" class="layui-btn layui-btn-normal layui-btn-sm hisi-iframe-pop" hisi-data="{width: '1000px', height: '500px', title: '添加商品'}">&nbsp;添加</a>
    <a href="{:url('goods_export')}" class="layui-btn layui-btn-primary layui-icon layui-icon-play" width="460" height="270">&nbsp;导出</a>
    <button type="button" class="layui-btn" id="test1">
        <i class="layui-icon">&#xe67c;</i>导入excel
      </button>
</script>
<script type="text/javascript">
    layui.use(['table'], function() {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            ,url: '{:url()}' //数据接口
            ,page: true //开启分页
            ,skin: 'row'
            ,even: true
            ,limit: 20
            ,text: {
                none : '暂无相关数据'
            }
            // ,toolbar: '#toolbar'
            ,defaultToolbar: ['filter']
            ,cols: [[ //表头
                {field: 'id', title: 'ID'}
                ,{title: '用户', templet: '#userTpl'}
                ,{field: 'openid', title: '用户openid'}
                ,{field: 'department', title: '所属部门'}
                ,{field: 'is_partner', title: '是否分销商'}
                ,{field: 'level', title: '分销等级'}
                ,{field: 'all_money', title: '累计佣金'}
                ,{field: 'rest_money', title: '可提现金额'}
                ,{field: 'jifen', title: '可用积分'}
                ,{title: '状态', templet: '#statusTpl'}
                ,{field: 'ctime', title: '创建时间'}
                ,{title: '操作', width: 120, templet: '#buttonTpl'}
            ]]
            ,done: function(){
                if (typeof(layui.global.addTableTool) !== 'undefined') {
                    layui.global.addTableTool();
                }
            }
        });
    });

    layui.use('upload', function(){
        var upload = layui.upload; //得到 upload 对象
        //创建一个上传组件
        upload.render({
        elem: '#test1'
        ,url: '{:url("goods_import")}'
        ,method:'post'
        ,done: function(res){ //上传后的回调
            // console.log(res);
            if(res.status=='success'){
                layer.msg('导入成功');
                window.location.reload();
            }
            else{
                layer.msg(res.msg);
            }
        } 
        ,accept: 'file' //允许上传的文件类型
        //,size: 50 //最大允许上传的文件大小
        //,……
        })
    });
</script>